<?php
$realms = array(
// "Realm name" => array(realmd_DB, characters_DB, mangos_DB, armory_DB)
"Your Realm Name 1" => array(1, 1, 1, 1),
//"Your Realm Name 2" => array(2, 2, 2, 2),
//"Your Realm Name 3" => array(3, 3, 3, 3),
);
// Default Realm Name (use one chosen upper in $realms)
define("DefaultRealmName", "Your Realm Name 1");
$realmd_DB = array(
// Connection to realmd DBs
1 => array("127.0.0.1:3306", "root", "root_pass", "realmd"),
//2 => array("127.0.0.2:3306", "root", "root_pass", "realmd2"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "realmd3"),
);
$characters_DB = array(
// Connection to characters DBs
1 => array("127.0.0.1:3306", "root", "root_pass", "characters"),
//2 => array("127.0.0.2:3306", "root", "root_pass", "characters2"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "characters3"),
);
$mangosd_DB = array(
// Connection to mangos DBs
1 => array("127.0.0.1:3306", "root", "root_pass", "mangos"),
//2 => array("127.0.0.2:3306", "root", "root_pass", "mangos2"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "mangos3"),
);
$armory_DB = array(
// Connection to armory DBs
1 => array("127.0.0.1:3306", "root", "root_pass", "armory"),
//2 => array("127.0.0.2:3306", "root", "root_pass", "armory2"),
//3 => array("127.0.0.3:3306", "root", "root_pass", "armory3"),
);
/* Don't touch anything beyond this point. */
set_time_limit(0);
ini_set("default_charset", "UTF-8");
set_magic_quotes_runtime(false);
function execute_query($query, $error = "")
{
	$query_result = @mysql_query($query);
	if($query_result)
		return $query_result;
	else
	{
		die($error.mysql_error());
		return false;
	}
}
function switchConnection($db_type, $realm_name)
{
	global $realms, $realmd_DB, $characters_DB, $mangosd_DB, $armory_DB;
	switch($db_type)
	{
		case "realmd": $needed_db = $realmd_DB[$realms[$realm_name][0]]; break;
		case "characters": $needed_db = $characters_DB[$realms[$realm_name][1]]; break;
		case "mangos": $needed_db = $mangosd_DB[$realms[$realm_name][2]]; break;
		/* armory */default: $needed_db = $armory_DB[$realms[$realm_name][3]];
	}
	mysql_connect($needed_db[0], $needed_db[1], $needed_db[2]) or die("Unable to connect to SQL host of ".$db_type." DB of realm ".$realm_name.": ".mysql_error());
	mysql_select_db($needed_db[3]) or die("Unable to connect to ".$db_type." DB of realm ".$realm_name.": ".mysql_error());
	execute_query("SET NAMES 'utf8'");
}
?>